package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.wms.domain.WarehouseArea;
import com.ruoyi.wms.service.IWarehouseAreaService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 库区库位Controller
 *
 * @author ruoyi
 * @date 2025-10-20
 */

@Api(value = "库区库位Controller", tags = "库区库位Controller")
@RestController
@RequestMapping("/area")
public class WarehouseAreaController extends BaseController {
    @Autowired
    private IWarehouseAreaService warehouseAreaService;

    /**
     * 查询库区库位列表
     */
    @RequiresPermissions("wms:area:list")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseArea warehouseArea) {
        startPage();
        List<WarehouseArea> list = warehouseAreaService.selectWarehouseAreaList(warehouseArea);
        return getDataTable(list);
    }



    /**
     * 获取库区库位详细信息
     */
    @RequiresPermissions("wms:area:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(warehouseAreaService.selectWarehouseAreaById(id));
    }


    /**
     * 修改库区库位
     */
    @RequiresPermissions("wms:area:edit")
    @Log(title = "库区库位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody@Validated WarehouseArea warehouseArea) {
        return toAjax(warehouseAreaService.updateWarehouseArea(warehouseArea));
    }

    /**
     * 删除库区库位
     */



    @Log(title = "库区库位", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(warehouseAreaService.deleteWarehouseAreaByIds(ids));
    }


}
